<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<% content_for :page_title, t('titles.access_report', 'Access Report') %>
<% add_crumb(t('#crumbs.people', 'People'), context_url(@context, :context_users_url))
  add_crumb(@user.name, context_url(@context, :context_user_url, @user))
  @active_tab="people"
  add_crumb(t('#crumbs.access_report', "Access Report"))
  css_bundle :roster_user_usage
%>
<% content_for :right_side do %>
  <a class="btn button-sidebar-wide" href="<%= context_url(@context, :context_user_url, @user) %>">
    <i class="icon-arrow-left"></i>
    {{#t}}Back to User Page{{/t}}
  </a>
<% end %>
<h1><%= t 'headings.user_access_report', '%{user} Access Report', :user => @user.name %></h1>
<div id="usage_report">
<table class="ic-Table">
  <thead>
    <tr>
      <th>{{#t}}Content{{/t}}</th>
      <th style="text-align: right;">{{#t}}Times Viewed{{/t}}</th>
      <th style="text-align: right;">{{#t}}Times Participated{{/t}}</th>
      <th>{{#t}}Last Viewed{{/t}}</th>
    </tr>
  </thead>
  <tbody>
    <% @accesses.each do |access| %>
      <tr class="access <%= access.asset_class_name %>">
        <td class="name_holder">
          <i class="icon <%= access.icon %>" aria-hidden="true"></i>
          <span class="readable_name"><%= access.readable_name %></span>
        </td>
        <td class="view_score"><%= round_if_whole(access.corrected_view_score) %></td>
        <td class="participate_score"><%= access.participate_score %></td>
        <td class="last_viewed time_ago_date" data-timestamp="<%= access.last_access.try_rescue(:iso8601) %>"><%= datetime_string(access.last_access) %></td>
      </tr>
    <% end %>
    <tr class="access blank" style="display: none;">
      <td class="name_holder">
        <i class="icon" aria-hidden="true"></i>
        <span class="readable_name">&nbsp;</span>
      </td>
      <td class="view_score">&nbsp;</td>
      <td class="participate_score">&nbsp;</td>
      <td class="last_viewed time_ago_date">&nbsp;</td>
    </tr>
  </tbody>
</table>
</div>
<%= will_paginate(@accesses) %>
<% js_bundle 'legacy/context_roster_usage' %>
